<?php
namespace App\Controller;

class TextareasController extends AppController{

    public function initialize()
    {
        parent::initialize();
    }

    /*
   * create by phpstorm
   * author：Ming
   * date：2020.04.18
   * ps：获取文本信息
   * */
    public function getInfo()
    {
        if(!$this->request->is("post")){
            $this->G->error("post_error");
            return null;
        }
        $content_type = $this->request->getData('content_type');
        $content_id = $this->request->getData('content_id');
        if(empty($content_type)){
            $this->G->error("content_type_error");
            return null;
        }
        if(!is_numeric($content_id)){
            $this->G->error("content_id_error");
            return null;
        }
        $this->loadComponent('TextareaCache');
        $textarea = $this->TextareaCache->getVal($content_type, $content_id);
        $this->loadComponent('ContentFormat');
        $textarea  = empty($textarea) ? '' : $this->ContentFormat->add($textarea['content']);
        $this->G->success('Success', ['content'=>$textarea]);
    }
}
?>